<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="author" content="lijinbo" />
    <script type="text/javascript" src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
    <title>css导航平滑滚动</title>
    <style>
      .scroll-ctn {
        display: block;
        width: 100%;
        height: 300px;
        overflow-y: scroll;
        scroll-behavior: smooth;
        border: 1px solid grey;
      }
      .scroll-panel {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 300px;
      }
      .nav_max {
        padding: 16px 0;
      }
      .nav_item {
        padding: 8px;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <div class="nav_max">
        <a v-for="e in 10" :key="e" :href="`#n_${e}`" class="nav_item">
          <button>{{ e }}</button>
        </a>
      </div>
      <div class="scroll-ctn">
        <div v-for="e in 10" :key="e" :id="`n_${e}`" class="scroll-panel">{{ e }}</div>
      </div>
    </div>
    <hr />
    <p>
      文章参考：
      <a href="https://mp.weixin.qq.com/s/Lgq72E2p5jAIXg1GdttBOg" target="_blank">Scroll，你玩明白了嘛？</a>
    </p>
    <script>
      new Vue({
        el: '#app'
      })
    </script>
  </body>
</html>
